

import { game } from "../../../../script/game/control/game";
import { actionType, assetsType, cardType, schoolType } from "../../../../script/game/gameType";
import { ListItem } from "../../../../script/util/ListView/ListItem";
import { ccs } from "../../../../script/util/services";
import { touchExd } from "../../../../script/util/TouchExtend";

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends ListItem<schoolType> {
    
    //标题
    @property(cc.Label)
    title: cc.Label = null;

    //描述
    @property(cc.RichText)
    desc: cc.RichText = null;

    //影响
    @property(cc.Label)
    effect: cc.Label = null;

    //花费
    @property(cc.Label)
    price: cc.Label = null;

    //
    @property(cc.Label)
    score: cc.Label = null;

    @property(cc.Label)
    power: cc.Label = null;

    @property(cc.Node)
    icon: cc.Node = null;

    @property(cc.Node)
    pass: cc.Node = null;

    start () {

    }
    initItem(data: schoolType, index: number) {
        ccs.spriteExd.setSprite(this.icon, ccs.resMgr.getSchoolIcon(data.id));
        this.title.string = data.name;
        this.desc.string = data.desc;
        this.price.string = "¥" + ccs.gf.getOmitNum(data.price);
        this.effect.string = ccs.gf.getEffectString(data.learn);
        this.power.string = "精力：" + data.power;
        this.score.string = `分数：${data.score}`;
    }
    onItemclick(data: schoolType) {
        ccs.winMgr.showWin('popAlert', {title: "上学提醒", content: `确定选择${data.name}吗？学费${data.price}/年，${data.year}年`, cb: () => {
            this.goSchool(data);
        }});
    }
    goSchool(data: schoolType) {
        //
        game.playerMgr.goSchool(data);
    }
}
